/*
Input: tmp/voter_id_panel_raw.dta [balanced panel of voter-addresses]
	
Output: tmp/voter_id_panel.dta [voter-addresses with added polling places]

Main task:
	> merge address panel with info on polling locations 

*/

* PULL: balanced voter-address panel 
	use "$tmp/voter_id_panel_raw.dta", clear 
	
	
 ** MERGE polling locations to precincts
	merge m:1 sb wahl_id using "$tmp/wl_sb_assignments_clean.dta", assert(3) nogen
	
	
*SAVE: balanced panel of geocoded voter-addresses + assigned (geocod.) polling locations
	order voter_id wahl* sb stadtbez lat_vote lon_vote wl_id lat_wl lon_wl
	isid voter_id wahl_id
	compress	
	save "$tmp/voter_id_panel.dta", replace
